import 'package:flutter/material.dart';
import 'package:myturngame/Theme.dart';
import 'package:myturngame/bean/role_in_map.dart';
import 'package:myturngame/widget/text_decoration.dart';

import '../../bean/role.dart';

class HomeRolesLayout extends StatelessWidget {
  List<RoleInMap> roleList;
  Function roleClick;

  HomeRolesLayout(this.roleList, this.roleClick, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    if(roleList.isEmpty){
      return Container();
    }

    return Container(
      padding: const EdgeInsets.all(10),
      decoration: BoxDecoration(color: Colors.grey,borderRadius: BorderRadius.circular(10)),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [nameList(roleClick)],
      ),
    );
  }

  Widget nameList(Function enemyClick) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: roleList
          .map((e) => GestureDetector(
              onTap: () {
                enemyClick(e);
              },
              child: Padding(
                  padding: const EdgeInsets.all(5),
                  child: BorderContainer(
                    Text(
                      e.name,
                      style: textStyle,
                    ),
                  ))))
          .toList(),
    );
  }
}
